<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>香型--个性化定制</title>
		<include file="public/comm" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav fs_xl">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left fs_xxi"></a>
			<h1 class="mui-title fs_xl">{$theCate['name']}</h1>
		</header>
		<include file="public/bottom_nav" />
		<div class="bx_check fs_xl"><span class="fs_m"><if empty($categoryname)>{$categorylist[0][title]}<else>{$categoryname['title']}</else></if></span><i class="mui-icon iconfont icon-sanjiaoxing-copy-copy fs_xi"></i></div>
		<div class="bx_box">
			<div class="bx_xz fs_s cls">
				<ul>
					<if empty($categoryname)>
						<foreach name="categorylist" item="vo" key="k">
							<li <if $k==0>class="bx_right"</if> >
								<a href="{:U('Destine/category',array('type'=>$theCate['type'],'id'=>$vo.id))}" class=""><if $k==0><i class="mui-icon mui-icon-checkmarkempty fs_xi"></i></if><em class="fs_xs">{$vo.title}</em></a>
							</li>						
						</foreach>
					<else>
						<foreach name="categorylist" item="vo" key="k">
							<li <if $categoryname['id']==$vo.id>class="bx_right"</if> >
								<a href="{:U('Destine/category',array('type'=>$theCate['type'],'id'=>$vo.id))}" class=""><if $categoryname['id']==$vo.id><i class="mui-icon mui-icon-checkmarkempty fs_xi"></i></if><em class="fs_xs">{$vo.title}</em></a>
							</li>						
						</foreach>
					</else>	
					</if>
				</ul>
			</div>
			<div class="bx_bl"></div>
		</div>
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper anli fs_xl">
			<div class="mui-scroll fs_xl al_list">
				<div class="mui-table-view mui-table-view-chevron" style="background: transparent;">
					<ul class="cls">
					<foreach name="goodslist" item="vo" key="k">
						<li>
							<a href="{:U('Destine/goodsInfo',array('id'=>$vo.goods_id))}"><img src="{$vo.goods_id|goods_thum_images=400,400}" /></a>
							<p><a class="fs_xs" href="{:U('Destine/goodsInfo',array('id'=>$vo.goods_id))}">我要定制</a><em class="fs_m">{$vo.goods_name}</em></p>
							<p class="cls"><span class="fs_xl">¥{$vo.shop_price}</span><span class="fs_xs">{$vo.sales_sum}已售</span></p>
						</li>
					</foreach>
					</ul>
				</div>
			</div>
		</div>
		<!--<div class="mui-content sp_top fs_xl" style="overflow: auto; height: 100%;">
		<div class="al_list cls">
			<ul class="cls">
				<foreach name="goodslist" item="vo" key="k">
				<li>
					<a href="/mobile/destine/goodsInfo/id/{$vo.goods_id}"><img src="__STATIC__/images/shop001.png" /></a>
					<p><a class="fs_xs" href="javascript:;">我要定制</a><em class="fs_m">{$vo.goods_name}</em></p>
					<p class="cls"><span class="fs_xl">¥{$vo.shop_price}</span><span class="fs_xs">{$vo.sales_sum}已售</span></p>
				</li>
				</foreach>
			</ul>
		</div>
		</div>-->
		<script>
			mui.init({
				pullRefresh: {
					container: '#pullrefresh',
//					down: {
//						callback: pulldownRefresh
//					},
					up: {
						contentrefresh: '正在加载...',
						callback: pullupRefresh
					}
				}
			});
			var count = 0;
//			var pagenum = {$pagenum};
			var pagenum = 1;
			var limit = 10; //设置请求条数
			/**
			 * 上拉加载具体业务实现
			 */
			function pullupRefresh() {
				setTimeout(function() {
					mui('#pullrefresh').pullRefresh().endPullupToRefresh((++count >= pagenum)); //参数为true代表没有更多数据了。
					getdatas('pullRefresh', limit * count);
				}, 1500);
			}
			$(function() {
				var bx_top = $(".bx_check").height() + $("header").height()+1;
				$(".bx_box").height($(window).height() - $(".bx_check").height() - $("header").height());
				$(".bx_box").css("top", bx_top);
				$(".bx_check").click(function() {
					if($(".bx_check i").hasClass("icon-sanjiaoxing-copy")){
						$(".bx_box").show();
						$(".bx_check i").removeClass("icon-sanjiaoxing-copy");
					}else{
						$(".bx_box").hide();
						$(".bx_check i").addClass("icon-sanjiaoxing-copy");
					}
				});
				$(".bx_xz li").click(function() {
					if($(this).find("i").length <= 0) {
						$(this).addClass("bx_right").siblings().removeClass("bx_right");
						$(this).find("a").prepend('<i class="mui-icon mui-icon-checkmarkempty fs_xi"></i>');
						$(this).siblings().find("i").remove();
					}
				});
				var winW = $(window).width();
				var liW = (winW - 1) / 2;
//				var alW = (winW - 5) / 2;
//				$(".al_list li").width(alW);
				$(".bx_bl").height($(".bx_box").height()-$(".bx_xz").height());
				$(".bx_bl").click(function(){
					$(".bx_box").hide();
					$(".bx_check i").addClass("icon-sanjiaoxing-copy");
				});
				$(".al_list").on('tap',"li",function() {
  					var sur=$(this).find("a").attr("href");
  					mui.openWindow({
    					url: sur
  					});
				});
			})
		</script>
		<script>
			mui.init();

			//Ajax请求数据,mod为pullRefresh则是上拉加载数据，不需要重置数据，其他情况则必须重置数据
			function getdatas(mod, start) {
				var aroma_id = $('#aroma li.ch_right').attr("data-val");
				var degree = $('#degree li.ch_right').attr("data-val");
				var years = $('#years li.ch_right').attr("data-val");
				var theme_id = $('#theme li.ch_right').attr("data-val");
				var origin_id = $('#origin li.ch_right').attr("data-val");
                console.log(years);
				$.post("{:U('Destine/category')}", {
					'start': start,
					'limit': limit,
					'aroma_id': aroma_id,
					'degree': degree,
					'years': years,
					'theme_id': theme_id,
					'origin_id': origin_id,
				}, function(content) {
					if(content.status == 1) {
						if(mod != 'pullRefresh') {
							$("#goodslist").html(" "); //重置数据
						}
						pagenum = content.data.pagenum;
						$.each(content.data.searchgoods, function(i, goods) {
                            var li = document.createElement('li');
							li.className = 'mui-table-view-cell';
							li.innerHTML = '<a href="{:U('Destine/goodsInfo',array('id'=>$vo.goods_id))}">' + '<img src="'+goods.original_img+'" />' + '</a>' +
								'<p>' + '<a class="fs_xs" href="javascript:;">我要定制' + '</a>' + '<em class="fs_m">'+goods.goods_name+ '</em>' + '</p>' +
								'<p class="cls">' + '<span class="fs_xl">¥'+goods.shop_price+ '</span>' + '<span class="fs_xs">6575已售' + '</span>' + '</p>';
							$("#goodslist").append(li);
						});
						$(".mui-pull").show();
					} else {
						if(mod != 'pullRefresh') {
							$("#goodslist").html("<center>暂无相关商品</center>");
							$(".mui-pull").hide();
						}
					}
				}, 'json');

			}
		</script>
	</body>

</html>